package org.jivesoftware.smackx.pubsub;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class PublishItem<T extends Item> extends NodeExtension
{
  protected Collection<T> items;

  public PublishItem(String paramString, Collection<T> paramCollection)
  {
    super(PubSubElementType.PUBLISH, paramString);
    this.items = paramCollection;
  }

  public PublishItem(String paramString, T paramT)
  {
    super(PubSubElementType.PUBLISH, paramString);
    this.items = new ArrayList(1);
    this.items.add(paramT);
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder("<");
    localStringBuilder.append(getElementName());
    localStringBuilder.append(" node='");
    localStringBuilder.append(getNode());
    localStringBuilder.append("'>");
    Iterator localIterator = this.items.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        localStringBuilder.append("</publish>");
        return localStringBuilder.toString();
      }
      localStringBuilder.append(((Item)localIterator.next()).toXML());
    }
  }
}